package com.xmread.cn.network;

import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.security.cert.X509Certificate;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;

public class SSLFactoryManager {
    public static SSLSocketFactory getDefaultTrust() {
        SSLContext sSLContext;
        X509TrustManager r0 = new X509TrustManager() {
            public void checkClientTrusted(X509Certificate[] x509CertificateArr, String str) {
            }

            public void checkServerTrusted(X509Certificate[] x509CertificateArr, String str) {
            }

            public X509Certificate[] getAcceptedIssuers() {
                return new X509Certificate[0];
            }
        };
        try {
            sSLContext = SSLContext.getInstance("SSL");
            sSLContext.init(null, new TrustManager[]{r0}, new SecureRandom());
        } catch (Exception e) {
//                e = e;
            e.printStackTrace();
            return null;
        }

        return sSLContext.getSocketFactory();
    }

    public static HostnameVerifier getDefaultHostnameVerifierTrust() {
        return new HostnameVerifier() {
            public boolean verify(String str, SSLSession sSLSession) {
                return true;
            }
        };
    }
}
